home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VDOSPNT.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  6KB  |  163 lines

  1. ;«RM82»«TS8,16,24,32,40,48,56,64»
  2. ; Updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13.  
  14. DOSSEG
  15. .model medium, Basic
  16. .code
  17.  
  18. ;============================================================================
  19. ; DECLARE FUNCTION DOSPRINT% (BYVAL Row%, BYVAL Col%, Text$)
  20. ; Uses DOS Write services to print to STDERR.  STDERR allways == CON.
  21. ; Does not change the current background attribute, uses whatever was there.
  22. ; Only prints to page 0, but no range checks on ROW and COL.
  23. ; Returns:
  24. ;        Error code:
  25. ;         0 if no error
  26. ;        -1 if ASCII CHR$(26) found in input stream
  27. ;
  28. ; Warning:
  29. ;        Assumes Text$ only contains ASCII text or Carriage return
  30. ;        control characters.  Any other control characters, e.g. CTRL-C
  31. ;        will cause Program to terminate, probably destroying file.
  32. ;        Routine checks for CTRL-C, CTRL-S, CTRL-P after each character
  33. ;
  34. ; Notes:
  35. ; Moves the cursor to the beginning of the string.  However does not tell
  36. ; QBASIC the current cursor location.  Should be a well managed function
  37. ; under WINDOWS or other multitasker.
  38. ;============================================================================
  39.  
  40. EVEN
  41. DOSPRINT Proc FAR BASIC ROW:Ptr, COL:Ptr, TEXTSTRG:Ptr
  42.  
  43. comment |
  44.      Register usage when all done:
  45.      CX = Length of Text string.
  46.      DX = Offset within DGROUP of String
  47.      DS = Assumed to point to segment containing Text string.
  48.           Program does not set this, so string is assumed to
  49.           be a near string in DGROUP, the default in QB 4.5
  50.      BX = is used as a scratch variable register
  51.      AX = returns 0 if no error, else error code
  52.      |
  53.                ;move cursor to beginning of print location
  54.     Mov   BX,ROW       ;NOTE uses BYVAL
  55.     Dec   BL           ;make it zero based
  56.     Mov   DH,BL        ;store ROW in DH
  57.     Mov   BX,COL       ;NOTE uses BYVAL
  58.     Dec   BL           ;make it zero based
  59.     Mov   DL,BL        ;store COL in DL
  60.     Xor   BH,BH        ;select page 0
  61.     Mov   AH,2         ;move cursor to desired location
  62.     Int   10h          ;using BIOS
  63.     Mov   BX,TEXTSTRG  ;put descriptor to TEXT$ into BX
  64.     Mov   CX,[BX]      ;put Len(TEXT$) into CX for loop counter
  65.     JCXZ  Error        ;if CX = 0, it's a null string, exit with Error
  66.     Mov   DX,[BX+02]   ;put address of first character in X$ into DX
  67.     Mov   BX,2         ;set handle of STDERR
  68.     Mov   AH,40h       ;Use DOS write to device function
  69.     Int   21h
  70.     JC    Exit         ;if carry set, error reported in AX
  71.     Cmp   CX,AX        ;did DOS receive number of characters sent?
  72.     JNE   Error        ;if no, report error
  73.     Xor   AX,AX        ;else clear AX to report no error
  74.     Jmp   Short Exit   ;now exit
  75. Error:
  76.     Mov   AX,-1        ;use -1 to report 01Ah found in input stream,
  77.                ;or report input stream was a null
  78. Exit:
  79.     Xor   DX,DX
  80.     Ret                ;return skipping the passed parameters
  81. DOSPRINT  Endp
  82.  
  83. ;============================================================================
  84. ; DECLARE FUNCTION DMPRINT% (BYVAL Row%, BYVAL Col%, Text$)
  85. ; Uses DOS Write services to print to STDERR.  STDERR allways == CON.
  86. ; Does not change the current background attribute, uses whatever was there.
  87. ; Only prints to page 0, but no range checks on ROW and COL.
  88. ; Returns:
  89. ;        Error code:
  90. ;         0 if no error
  91. ;        -1 if CON error.
  92. ;
  93. ; Warning:
  94. ;        Ignores any control characters, merely prints string.
  95. ;
  96. ; Notes:
  97. ; Moves the cursor to the beginning of the string.  However does not tell
  98. ; QBASIC the current cursor location.  Should be a well managed function
  99. ; under WINDOWS or other multitasker.
  100. ;
  101. ; Routine is about 1.23 times faster than DOSPRINT on an EGA
  102. ;============================================================================
  103.  
  104. CON_STATUS    DB    0    ;save original status of CON
  105.  
  106. EVEN
  107. DMPRINT Proc FAR BASIC ROW:Ptr, COL:Ptr, TEXTSTRG:Ptr
  108.  
  109. comment |
  110.      Register usage when nearly done:
  111.      CX = Length of Text string.
  112.      DX = Offset within DGROUP of String
  113.      DS = Assumed to point to segment containing Text string.
  114.       Program does not set this, so string is assumed to
  115.       be a near string in DGROUP, the default in QB 4.5
  116.      BX = is used as a scratch variable register
  117.      AX = returns 0 if no error, else error code
  118.      |
  119.     Mov   AX,4400h     ;get current mode of STDERR
  120.     Mov   BX,2         ;set BX to STDERR handle
  121.     Int   21h
  122.     Xor   DH,DH        ;clear DH
  123.     Mov   CON_STATUS,DL  ;save current CON status
  124.     Or    DL,20h       ;set BINARY or RAW bit
  125.     Mov   AX,4401h     ;do it
  126.     Int   21h
  127.                ;move cursor to beginning of print location
  128.     Mov   BX,ROW       ;NOTE uses BYVAL
  129.     Dec   BL           ;make it zero based
  130.     Mov   DH,BL        ;store ROW in DH
  131.     Mov   BX,COL       ;NOTE uses BYVAL
  132.     Dec   BL           ;make it zero based
  133.     Mov   DL,BL        ;store COL in DL
  134.     Xor   BH,BH        ;select page 0
  135.     Mov   AH,2         ;move cursor to desired location
  136.     Int   10h          ;using BIOS
  137.     Mov   BX,TEXTSTRG  ;put descriptor to TEXT$ into BX
  138.     Mov   CX,[BX]      ;put Len(TEXT$) into CX for loop counter
  139.     JCXZ  Error        ;if CX = 0 it's a null string, exit with an error
  140.     Mov   DX,[BX+02]   ;put address of first character in X$ into DX
  141.     Mov   BX,2         ;set handle to STDERR
  142.     Mov   AH,40h       ;write to device function
  143.     Int   21h
  144.     JC    Exit         ;if carry set, error reported in AX
  145.     Cmp   CX,AX        ;did DOS receive number of characters sent?
  146.     JNE   Error        ;if no, report error of -1
  147.     Xor   AX,AX        ;else clear AX to report no error
  148.     Jmp   Short Exit   ;now exit
  149. Error:
  150.     Mov   AX,-1        ;use -1 to report CON error, input stream a Null.
  151. Exit:
  152.     Mov   CX,AX        ;save AX in CX
  153.     Mov   BX,2         ;Set BX to STDERR handle
  154.     Xor   DH,DH        ;clear DH
  155.     Mov   DL,CON_STATUS ;restore CON to original status
  156.     Mov   AX,4401h     ;do it
  157.     Int   21h
  158.     Xor   DX,DX        ;clear DX in case call long
  159.     Mov   AX,CX        ;get error code back from CX
  160.     Ret                ;return skipping the passed parameters
  161. DMPRINT  Endp
  162. END
  163.